﻿using Glue;
using Xunit;

namespace GlueTests.MapperVerificationTests
{
    public class When_mapping_between_enums
    {
        private readonly Mapping<DomainThing, GuiThing> mapping;

        public enum SameEnum
        {
            FirstValue,
            SecondValue
        }

        public class DomainThing
        {
            public SameEnum TheEnum { get; set; }
        }

        public class GuiThing
        {
            public SameEnum TheEnum { get; set; }
        }

        public When_mapping_between_enums()
        {
            mapping = new Mapping<DomainThing, GuiThing>();
            mapping.AutoRelateEqualNames();
        }

        [Fact]
        public void Should_map_between_same_type_of_enum()
        {
            var guiObject = mapping.Map(new DomainThing {TheEnum = SameEnum.SecondValue}, new GuiThing {TheEnum = SameEnum.FirstValue});
            Assert.Equal(SameEnum.SecondValue,guiObject.TheEnum);
        }

        [Fact]
        public void Should_verify_relations_mapping_towards_right()
        {
            mapping.GetRelationsVerification().AssertAllPropertiesRelated<GuiThing>();
        }

        [Fact]
        public void Should_verify_relations_mapping_towards_left()
        {
            mapping.GetRelationsVerification().AssertAllPropertiesRelated<DomainThing>();
        }

        [Fact]
        public void Should_verify_mapping_towards_right()
        {
            mapping.GetMapperVerification().AssertMapsCorrectlyTowards(new GuiThing());
        }

        [Fact]
        public void Should_verify_mapping_towards_left()
        {
            mapping.GetMapperVerification().AssertMapsCorrectlyTowards(new DomainThing());
        }
    }
}